package iscte.ai.kcgtd;

public abstract class CalendarBlocks implements Comparable<CalendarBlocks> {

	private KCGTDTime startTime;
	private KCGTDTime endTime;
	private KCGTDTime duration;

	public CalendarBlocks(KCGTDTime startTime, KCGTDTime endTime) {
		this.startTime = startTime;
		this.endTime = endTime;

		int second = endTime.getSecond() - startTime.getSecond();
		int minute = endTime.getMinute() - startTime.getMinute();
		int hour = endTime.getHour() - startTime.getHour();
		int monthDay = endTime.getMonthDay() - startTime.getMonthDay();
		int month = endTime.getMonth() - startTime.getMonth();
		int year = endTime.getYear() - startTime.getYear();
		
		if(minute < 0){
			hour--;
			minute = 60+minute;
		}
		
		duration = new KCGTDTime(second, minute, hour, monthDay, month, year);
	}

	public KCGTDTime getStartTime() {
		return startTime;
	}

	public KCGTDTime getEndTime() {
		return endTime;
	}

	public KCGTDTime getDuration() {
		return duration;
	}

	public void setStartTime(KCGTDTime startTime) {
		this.startTime = startTime;
	}

	public void setEndTime(KCGTDTime endTime) {
		this.endTime = endTime;
	}

	public void setStartHour(int hour){
		startTime.setHour(hour);
	}

	public void setStartMinute(int minute){
		startTime.setMinute(minute);
	}

	public void setEndHour(int hour){
		endTime.setHour(hour);
	}

	public void setEndMinute(int minute){
		endTime.setMinute(minute);
	}

	public void updateDuration(){
		duration = Utils.getDurationBetweenHours(startTime, endTime);
	}
	
}
